package com.dayu.demo.pojo;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Map;
import java.math.BigDecimal;
import com.vecspace.data.model.RowMapper;
import com.vecspace.data.model.IdEntity;
import com.vecspace.dicttable.DictAll;
import org.hibernate.annotations.Polymorphism;
import org.hibernate.annotations.PolymorphismType;
import com.fasterxml.jackson.annotation.JsonIgnore;
import javax.persistence.Table;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Transient;
import com.vecspace.data.model.IDataLockState;


/** 部门
 * @template dayu-code-builder
 * @author user
 * @reviewer 
 * @createTime 2021-11-24 15:11:41
 * @version 1.0
 */
@Entity
@Polymorphism(type = PolymorphismType.EXPLICIT)
@Table(name = "T_DEMO_DEPARTMENT")
public class Department implements IdEntity, IDataLockState, java.io.Serializable {

    public Department(){
    }
    
    private static final long serialVersionUID = 10014L;

    /** ID */
    private Long id;
    /** 部门名称 */
    private String name;
    /** 上级部门ID */
    private Long parentId;
    /** 部门类型 */
    private String administrativeCategory;
    /** 所在地址 */
    private String addr;
    /** 备注 */
    private String remarks;
    /** 顺序号 */
    private Integer ordnum;
    /** 租户ID */
    private Long tenantId;
    /** 锁定状态 */
    private Integer rowLock;
    /** 记录创建时间 */
    private LocalDateTime createTime;
    /** 记录创建人ID */
    private Long createUser;


/****************************** getter setter *******************************************/


    /**ID*/
    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "ID")
    public Long getId(){
        return id;
    }

    /**ID*/
    public void setId(Long value){
        this.id = value;
    }

    /**部门名称*/
    @Column(name = "NAME_")
    public String getName(){
        return name;
    }

    /**部门名称*/
    public void setName(String value){
        this.name = value;
    }

    /**上级部门ID*/
    @Column(name = "PARENT_ID")
    public Long getParentId(){
        return parentId;
    }

    /**上级部门ID*/
    public void setParentId(Long value){
        this.parentId = value;
    }

    /**部门类型*/
    @Column(name = "ADMINISTRATIVE_CATEGORY")
    public String getAdministrativeCategory(){
        return administrativeCategory;
    }

    /**部门类型*/
    public void setAdministrativeCategory(String value){
        this.administrativeCategory = value;
    }

    /**所在地址*/
    @Column(name = "ADDR")
    public String getAddr(){
        return addr;
    }

    /**所在地址*/
    public void setAddr(String value){
        this.addr = value;
    }

    /**备注*/
    @Column(name = "REMARKS")
    public String getRemarks(){
        return remarks;
    }

    /**备注*/
    public void setRemarks(String value){
        this.remarks = value;
    }

    /**顺序号*/
    @Column(name = "ORDNUM")
    public Integer getOrdnum(){
        return ordnum;
    }

    /**顺序号*/
    public void setOrdnum(Integer value){
        this.ordnum = value;
    }

    /**租户ID*/
    @JsonIgnore(true)
    @Column(name = "TENANT_ID")
    public Long getTenantId(){
        return tenantId;
    }

    /**租户ID*/
    public void setTenantId(Long value){
        this.tenantId = value;
    }

    /**锁定状态*/
    @Column(name = "ROW_LOCK")
    public Integer getRowLock(){
        return rowLock;
    }

    /**锁定状态*/
    public void setRowLock(Integer value){
        this.rowLock = value;
    }

    /**记录创建时间*/
    @JsonIgnore(true)
    @Column(name = "CREATE_TIME")
    public LocalDateTime getCreateTime(){
        return createTime;
    }

    /**记录创建时间*/
    public void setCreateTime(LocalDateTime value){
        this.createTime = value;
    }

    /**记录创建人ID*/
    @JsonIgnore(true)
    @Column(name = "CREATE_USER")
    public Long getCreateUser(){
        return createUser;
    }

    /**记录创建人ID*/
    public void setCreateUser(Long value){
        this.createUser = value;
    }

    public void parseFrom(Map<String, Object> row){
        RowMapper rowMapper = new RowMapper(row);
        this.id = rowMapper.getLong("ID");
        this.name = rowMapper.getString("NAME_");
        this.parentId = rowMapper.getLong("PARENT_ID");
        this.administrativeCategory = rowMapper.getString("ADMINISTRATIVE_CATEGORY");
        this.addr = rowMapper.getString("ADDR");
        this.remarks = rowMapper.getString("REMARKS");
        this.ordnum = rowMapper.getInteger("ORDNUM");
        this.tenantId = rowMapper.getLong("TENANT_ID");
        this.rowLock = rowMapper.getInteger("ROW_LOCK");
        this.createTime = rowMapper.getLocalDateTime("CREATE_TIME");
        this.createUser = rowMapper.getLong("CREATE_USER");
    }

    @Override
    public boolean equals(Object obj) {
        if(obj == null)return false;
        if(id == null)return false;
        Department other = (Department)obj;
        return id.equals(other.id);
    }

    @Override
    public int hashCode() {
        if(id == null)return 0;
        return id.hashCode();
    }
}
